package com.qgs.secsgem.secs.controller.pid18;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.qgs.secsgem.mq.entity.specificBody.QueryEQStatusBody;
import com.qgs.secsgem.secs.eq.runnable.PID18Runnable;
import com.qgs.secsgem.secs.entity.MesRequestMessage;
import com.qgs.secsgem.secs.entity.common.*;
import com.qgs.secsgem.secs.entity.eventBody.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * DESC : 发送给EAP-Client 的 指令集 案例
 * */
@RestController
@RequestMapping("/testPID18")
public class PID18MESTestPushController {
    private static final Logger logger = LoggerFactory.getLogger(PID18MESTestPushController.class);



    public static List<ValueNode> get(JSONArray argList){
        List<ValueNode> set = new ArrayList<>();

        for(int i=0;i<argList.size();i++){
            if(argList.get(i) == null){
                continue;
            }
            JSONObject j = (JSONObject) argList.get(i);
            String type = j.getString("f");
            if(!type.equals("L")){
                set.add(new ValueNode(j.getString("f"),j.get("v").toString()));

            }else {
                //当嵌套里面还有嵌套，，这里顺序错了，修复一下。
                JSONArray array = j.getJSONArray("v");
                set.add(new ValueNode("List",get(array)));
            }
        }
        return set;
    }

    @PostMapping("/S1F1")
    public void S1F1() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","GeneratePingRequest","pid18");
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }
    @PostMapping("/S1F3")
    public void S1F3() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","QUERYEQStatus","pid18");

        List<String> s = new ArrayList<>();
        s.add("11");  //CommunicationState
        s.add("60");  //E10State
        s.add("72");  //PPExecName

        S1F3MesRequestBody s1F3MesRequestBody = new S1F3MesRequestBody(s,PID18Runnable.SVID_Type);
        mesResponse.setBody(JSONObject.toJSONString(s1F3MesRequestBody));
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S1F15")
    public void S1F15() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestOffLine","pid18");
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S1F17")
    public void S1F17() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestONLine","pid18");
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S1F11")
    public void S1F11() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","QUERYSVNameList","pid18");
        QueryEQStatusBody queryEQStatusBody = new QueryEQStatusBody();
        queryEQStatusBody.setVidType(PID18Runnable.SVID_Type);
        List<String> vids = new ArrayList<>();
        vids.add("10000");
        vids.add("10001");
        vids.add("10002");
        queryEQStatusBody.setVidList(vids);
        mesResponse.setBody(JSONObject.toJSONString(queryEQStatusBody));
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S1F13")
    public void S1F13() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","EstablishCommunication","pid18");
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));

        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F13")
    public void S2F13() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestEQPConstant","pid18");
        List<String> ecids = new ArrayList<>();
        ecids.add("4");
        ecids.add("8");
        ecids.add("9");


        mesResponse.setBody(JSONObject.toJSONString(new S2F13MesRequestBody(PID18Runnable.ECID_Type,ecids)));
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }



    @PostMapping("/S2F15")
    public void S2F15() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","UpdateEC","pid18");

        List<ECNode> ecids = new ArrayList<>();
        ecids.add(new ECNode("8","2","U4"));
        ecids.add(new ECNode("4","false","Boolean"));

        mesResponse.setBody(JSONObject.toJSONString(new S2F15MesRequestBody(PID18Runnable.ECID_Type,ecids)));
        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }


    @PostMapping("/S2F17")
    public void S2F17() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestDateTime","pid18");

        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F23")
    public void S2F23() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","TraceInit","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<String> vidList = new ArrayList<>();
        vidList.add("11");
        vidList.add("13");
        vidList.add("14");
        TraceNode traceNode = new TraceNode("100a","A","000002",100,"U4",1,"U1",PID18Runnable.SVID_Type,vidList);

        mesResponse.setBody(JSONObject.toJSONString(traceNode));
        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F29")
    public void S2F29() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestECNameList","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<String> ecids = new ArrayList<>();
        ecids.add("4");
        ecids.add("8");
        ecids.add("9");
        S2F29MesRequestBody s2F29MesRequestBody = new S2F29MesRequestBody(ecids,PID18Runnable.ECID_Type);
        mesResponse.setBody(JSONObject.toJSONString(s2F29MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }
    private ReportNode createReport(String reportId,String reportIdType,List<ValueNode> valueNodes) {
        ReportNode reportNode = new ReportNode();
        reportNode.setReportId(reportId);
        reportNode.setReportIdType(reportIdType);
        reportNode.setValueList(valueNodes);
        return reportNode;
    }
    @PostMapping("/S2F33_define_report")
    public void S2F33() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","DefineReport","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<ReportNode> reportNodes = new ArrayList<>();

        //report1
        //注意：vids要按顺序
        //1. 这个代表给 reportId=1001 定义以下 vids
        List<ValueNode> vids1 = new ArrayList<>();
        vids1.add(new ValueNode("U4",3));
        vids1.add(new ValueNode("U4",500));
        vids1.add(new ValueNode("U4",11));
        vids1.add(new ValueNode("U4",13));
        vids1.add(new ValueNode("U4",14));
        //2. 这样代表 删除 reportId=1001  下的所有vids（因为vids 是空）
        reportNodes.add(createReport("1",PID18Runnable.REPORTID_Type,vids1));
        //report2
        List<ValueNode> vids2 = new ArrayList<>();
        vids2.add(new ValueNode("U4",3));
        vids2.add(new ValueNode("U4",500));
        vids2.add(new ValueNode("U4",11));
        vids2.add(new ValueNode("U4",13));
        vids2.add(new ValueNode("U4",14));
        reportNodes.add(createReport("2",PID18Runnable.REPORTID_Type,vids2));

        List<ValueNode> vids3 = new ArrayList<>();
        vids3.add(new ValueNode("U4",3));
        vids3.add(new ValueNode("U4",500));
        vids3.add(new ValueNode("U4",11));
        vids3.add(new ValueNode("U4",13));
        vids3.add(new ValueNode("U4",14));
        reportNodes.add(createReport("3",PID18Runnable.REPORTID_Type,vids3));

        List<ValueNode> vids11 = new ArrayList<>();
        vids11.add(new ValueNode("U4",3));
        vids11.add(new ValueNode("U4",5));
        vids11.add(new ValueNode("U4",6));
        vids11.add(new ValueNode("U4",7));
        reportNodes.add(createReport("11",PID18Runnable.REPORTID_Type,vids11));

        List<ValueNode> vids12 = new ArrayList<>();
        vids12.add(new ValueNode("U4",3));
        vids12.add(new ValueNode("U4",5));
        vids12.add(new ValueNode("U4",6));
        vids12.add(new ValueNode("U4",7));
        reportNodes.add(createReport("12",PID18Runnable.REPORTID_Type,vids12));

        List<ValueNode> vids21 = new ArrayList<>();
        vids21.add(new ValueNode("U4",3));
        vids21.add(new ValueNode("U4",41));
        vids21.add(new ValueNode("U4",45));
        vids21.add(new ValueNode("U4",46));
        vids21.add(new ValueNode("U4",47));
        vids21.add(new ValueNode("U4",48));
        reportNodes.add(createReport("21",PID18Runnable.REPORTID_Type,vids21));

        List<ValueNode> vids22 = new ArrayList<>();
        vids22.add(new ValueNode("U4",3));
        vids22.add(new ValueNode("U4",41));
        vids22.add(new ValueNode("U4",45));
        vids22.add(new ValueNode("U4",46));
        vids22.add(new ValueNode("U4",47));
        vids22.add(new ValueNode("U4",48));
        reportNodes.add(createReport("22",PID18Runnable.REPORTID_Type,vids22));

        List<ValueNode> vids23 = new ArrayList<>();
        vids23.add(new ValueNode("U4",3));
        vids23.add(new ValueNode("U4",41));
        vids23.add(new ValueNode("U4",45));
        vids23.add(new ValueNode("U4",46));
        vids23.add(new ValueNode("U4",47));
        vids23.add(new ValueNode("U4",48));
        reportNodes.add(createReport("23",PID18Runnable.REPORTID_Type,vids23));

        List<ValueNode> vids40 = new ArrayList<>();
        vids40.add(new ValueNode("U4",3));
        vids40.add(new ValueNode("U4",72));
        vids40.add(new ValueNode("U4",1000));
        vids40.add(new ValueNode("U4",1101));
        vids40.add(new ValueNode("U4",1100));
        reportNodes.add(createReport("40",PID18Runnable.REPORTID_Type,vids40));

        List<ValueNode> vids41 = new ArrayList<>();
        vids41.add(new ValueNode("U4",3));
        vids41.add(new ValueNode("U4",1000));
        vids41.add(new ValueNode("U4",1101));
        vids41.add(new ValueNode("U4",1100));
        reportNodes.add(createReport("41",PID18Runnable.REPORTID_Type,vids41));

        List<ValueNode> vids42 = new ArrayList<>();
        vids42.add(new ValueNode("U4",3));
        vids42.add(new ValueNode("U4",72));
        vids42.add(new ValueNode("U4",1002));
        vids42.add(new ValueNode("U4",1102));
        reportNodes.add(createReport("42",PID18Runnable.REPORTID_Type,vids42));

        List<ValueNode> vids43 = new ArrayList<>();
        vids43.add(new ValueNode("U4",3));
        vids43.add(new ValueNode("U4",72));
        vids43.add(new ValueNode("U4",1003));
        vids43.add(new ValueNode("U4",1103));
        vids43.add(new ValueNode("U4",1101));
        vids43.add(new ValueNode("U4",1108));
        vids43.add(new ValueNode("U4",2000));
        vids43.add(new ValueNode("U4",2001));
        vids43.add(new ValueNode("U4",2002));
        vids43.add(new ValueNode("U4",2003));
        vids43.add(new ValueNode("U4",2004));
        vids43.add(new ValueNode("U4",2005));
        vids43.add(new ValueNode("U4",2006));
        vids43.add(new ValueNode("U4",2007));
        vids43.add(new ValueNode("U4",2008));
        vids43.add(new ValueNode("U4",2009));
        vids43.add(new ValueNode("U4",2010));
        vids43.add(new ValueNode("U4",2011));
        vids43.add(new ValueNode("U4",2012));
        vids43.add(new ValueNode("U4",2013));
        vids43.add(new ValueNode("U4",2014));
        vids43.add(new ValueNode("U4",2015));
        vids43.add(new ValueNode("U4",2016));
        vids43.add(new ValueNode("U4",2017));
        vids43.add(new ValueNode("U4",2018));
        vids43.add(new ValueNode("U4",2019));
        vids43.add(new ValueNode("U4",2020));
        vids43.add(new ValueNode("U4",2021));
        vids43.add(new ValueNode("U4",2022));
        vids43.add(new ValueNode("U4",2023));
        vids43.add(new ValueNode("U4",2024));
        vids43.add(new ValueNode("U4",2025));
        vids43.add(new ValueNode("U4",2026));
        vids43.add(new ValueNode("U4",2027));
        vids43.add(new ValueNode("U4",2028));
        vids43.add(new ValueNode("U4",2029));
        vids43.add(new ValueNode("U4",2030));
        vids43.add(new ValueNode("U4",2031));
        vids43.add(new ValueNode("U4",2032));
        vids43.add(new ValueNode("U4",2033));
        vids43.add(new ValueNode("U4",2034));
        vids43.add(new ValueNode("U4",2035));
        vids43.add(new ValueNode("U4",2036));
        vids43.add(new ValueNode("U4",2037));
        vids43.add(new ValueNode("U4",2038));
        vids43.add(new ValueNode("U4",2039));
        vids43.add(new ValueNode("U4",2040));
        vids43.add(new ValueNode("U4",2041));
        vids43.add(new ValueNode("U4",2042));
        vids43.add(new ValueNode("U4",2043));
        vids43.add(new ValueNode("U4",2044));
        vids43.add(new ValueNode("U4",2045));
        vids43.add(new ValueNode("U4",2046));
        reportNodes.add(createReport("43",PID18Runnable.REPORTID_Type,vids43));

        List<ValueNode> vids44 = new ArrayList<>();
        vids44.add(new ValueNode("U4",3));
        vids44.add(new ValueNode("U4",72));
        vids44.add(new ValueNode("U4",1007));
        vids44.add(new ValueNode("U4",1107));
        vids44.add(new ValueNode("U4",1101));
        vids44.add(new ValueNode("U4",1108));
        reportNodes.add(createReport("44",PID18Runnable.REPORTID_Type,vids44));

        List<ValueNode> vids70 = new ArrayList<>();
        vids70.add(new ValueNode("U4",3));
        vids70.add(new ValueNode("U4",51));
        reportNodes.add(createReport("70",PID18Runnable.REPORTID_Type,vids70));

        List<ValueNode> vids80 = new ArrayList<>();
        vids80.add(new ValueNode("U4",3));
        vids80.add(new ValueNode("U4",60));
        vids80.add(new ValueNode("U4",61));
        reportNodes.add(createReport("80",PID18Runnable.REPORTID_Type,vids80));

        List<ValueNode> vids90 = new ArrayList<>();
        vids90.add(new ValueNode("U4",3));
        vids90.add(new ValueNode("U4",70));
        vids90.add(new ValueNode("U4",71));
        reportNodes.add(createReport("90",PID18Runnable.REPORTID_Type,vids90));

        List<ValueNode> vids91 = new ArrayList<>();
        vids91.add(new ValueNode("U4",3));
        vids91.add(new ValueNode("U4",70));
        vids91.add(new ValueNode("U4",71));
        reportNodes.add(createReport("91",PID18Runnable.REPORTID_Type,vids91));

        List<ValueNode> vids92 = new ArrayList<>();
        vids92.add(new ValueNode("U4",3));
        vids92.add(new ValueNode("U4",70));
        vids92.add(new ValueNode("U4",71));
        reportNodes.add(createReport("92",PID18Runnable.REPORTID_Type,vids92));

        List<ValueNode> vids93 = new ArrayList<>();
        vids93.add(new ValueNode("U4",3));
        vids93.add(new ValueNode("U4",70));
        vids93.add(new ValueNode("U4",71));
        reportNodes.add(createReport("93",PID18Runnable.REPORTID_Type,vids93));

        List<ValueNode> vids110 = new ArrayList<>();
        vids110.add(new ValueNode("U4",3));
        vids110.add(new ValueNode("U4",500));
        vids110.add(new ValueNode("U4",501));
        reportNodes.add(createReport("110",PID18Runnable.REPORTID_Type,vids110));

        List<ValueNode> vids111 = new ArrayList<>();
        vids111.add(new ValueNode("U4",3));
        vids111.add(new ValueNode("U4",500));
        vids111.add(new ValueNode("U4",501));
        reportNodes.add(createReport("111",PID18Runnable.REPORTID_Type,vids111));

        List<ValueNode> vids120 = new ArrayList<>();
        vids120.add(new ValueNode("U4",3));
        vids120.add(new ValueNode("U4",201));
        vids120.add(new ValueNode("U4",200));
        reportNodes.add(createReport("120",PID18Runnable.REPORTID_Type,vids120));

        List<ValueNode> vids121 = new ArrayList<>();
        vids121.add(new ValueNode("U4",3));
        vids121.add(new ValueNode("U4",201));
        vids121.add(new ValueNode("U4",200));
        reportNodes.add(createReport("121",PID18Runnable.REPORTID_Type,vids121));

        List<ValueNode> vids130 = new ArrayList<>();
        vids130.add(new ValueNode("U4",3));
        vids130.add(new ValueNode("U4",4200));
        vids130.add(new ValueNode("U4",4201));
        reportNodes.add(createReport("130",PID18Runnable.REPORTID_Type,vids130));

        S2F33MesRequestBody s2F33MesRequestBody = new S2F33MesRequestBody(reportNodes);
        mesResponse.setBody(JSONObject.toJSONString(s2F33MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid10",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F33_del_allReportAndLink")
    public void S2F33_del_allReportAndLink() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","DefineReport","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<ReportNode> reportNodes = new ArrayList<>();


        S2F33MesRequestBody s2F33MesRequestBody = new S2F33MesRequestBody(reportNodes);
        mesResponse.setBody(JSONObject.toJSONString(s2F33MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F33_del_OneReportAndLinkedEvent")
    public void S2F33_del_OneReportAndLinkedEvent() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","DefineReport","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<ReportNode> reportNodes = new ArrayList<>();

        List<ValueNode> vids = new ArrayList<>();
        //2. 这样代表 删除 reportId=1001  下的所有vids（因为vids 是空）
        reportNodes.add(createReport("1001",PID18Runnable.REPORTID_Type,vids));

        S2F33MesRequestBody s2F33MesRequestBody = new S2F33MesRequestBody(reportNodes);
        mesResponse.setBody(JSONObject.toJSONString(s2F33MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    private ReportEventNode createReportEvent(String ceid,String ceidType,List<ValueNode> valueNodes) {
        ReportEventNode reportEventNode = new ReportEventNode();
        reportEventNode.setCeid(ceid);
        reportEventNode.setCeidType(ceidType);
        reportEventNode.setValueNodes(valueNodes);
        return reportEventNode;
    }
    @PostMapping("/S2F35")
    public void S2F35() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","LinkEventReport","12");

        mesResponse.setHeader(header);

        //构建body   开始
        List<ReportEventNode> reportEventNodes = new ArrayList<>();

        //report-event link 1
        //注意：reportIds要按顺序
        //1. 这个代表给 ceid=101 定义以下 reportIds
        List<ValueNode> rptids1 = new ArrayList<>();
        rptids1.add(new ValueNode("U4",1));
        //2. 这样代表 删除 reportId=1001  下的所有vids（因为vids 是空）
        reportEventNodes.add(createReportEvent("1",PID18Runnable.CEID_Type,rptids1));

        //report-event link 2
        List<ValueNode> rptids2 = new ArrayList<>();
        rptids2.add(new ValueNode("U4",2));
        reportEventNodes.add(createReportEvent("2",PID18Runnable.CEID_Type,rptids2));

        List<ValueNode> rptids3 = new ArrayList<>();
        rptids3.add(new ValueNode("U4",3));
        reportEventNodes.add(createReportEvent("3",PID18Runnable.CEID_Type,rptids3));

        List<ValueNode> rptids11 = new ArrayList<>();
        rptids11.add(new ValueNode("U4",11));
        reportEventNodes.add(createReportEvent("11",PID18Runnable.CEID_Type,rptids11));

        List<ValueNode> rptids12 = new ArrayList<>();
        rptids12.add(new ValueNode("U4",12));
        reportEventNodes.add(createReportEvent("12",PID18Runnable.CEID_Type,rptids12));

        List<ValueNode> rptids21 = new ArrayList<>();
        rptids21.add(new ValueNode("U4",21));
        reportEventNodes.add(createReportEvent("21",PID18Runnable.CEID_Type,rptids21));

        List<ValueNode> rptids22 = new ArrayList<>();
        rptids22.add(new ValueNode("U4",22));
        reportEventNodes.add(createReportEvent("22",PID18Runnable.CEID_Type,rptids22));

        List<ValueNode> rptids23 = new ArrayList<>();
        rptids23.add(new ValueNode("U4",23));
        reportEventNodes.add(createReportEvent("23",PID18Runnable.CEID_Type,rptids23));

        List<ValueNode> rptids40 = new ArrayList<>();
        rptids40.add(new ValueNode("U4",40));
        reportEventNodes.add(createReportEvent("40",PID18Runnable.CEID_Type,rptids40));

        List<ValueNode> rptids41 = new ArrayList<>();
        rptids41.add(new ValueNode("U4",41));
        reportEventNodes.add(createReportEvent("41",PID18Runnable.CEID_Type,rptids41));

        List<ValueNode> rptids42 = new ArrayList<>();
        rptids42.add(new ValueNode("U4",42));
        reportEventNodes.add(createReportEvent("42",PID18Runnable.CEID_Type,rptids42));

        List<ValueNode> rptids43 = new ArrayList<>();
        rptids43.add(new ValueNode("U4",43));
        reportEventNodes.add(createReportEvent("43",PID18Runnable.CEID_Type,rptids43));

        List<ValueNode> rptids44 = new ArrayList<>();
        rptids44.add(new ValueNode("U4",44));
        reportEventNodes.add(createReportEvent("44",PID18Runnable.CEID_Type,rptids44));

        List<ValueNode> rptids70 = new ArrayList<>();
        rptids70.add(new ValueNode("U4",70));
        reportEventNodes.add(createReportEvent("70",PID18Runnable.CEID_Type,rptids70));

        List<ValueNode> rptids80 = new ArrayList<>();
        rptids80.add(new ValueNode("U4",80));
        reportEventNodes.add(createReportEvent("80",PID18Runnable.CEID_Type,rptids80));

        List<ValueNode> rptids90 = new ArrayList<>();
        rptids90.add(new ValueNode("U4",90));
        reportEventNodes.add(createReportEvent("90",PID18Runnable.CEID_Type,rptids90));

        List<ValueNode> rptids91 = new ArrayList<>();
        rptids91.add(new ValueNode("U4",91));
        reportEventNodes.add(createReportEvent("91",PID18Runnable.CEID_Type,rptids91));

        List<ValueNode> rptids92 = new ArrayList<>();
        rptids92.add(new ValueNode("U4",92));
        reportEventNodes.add(createReportEvent("92",PID18Runnable.CEID_Type,rptids92));

        List<ValueNode> rptids93 = new ArrayList<>();
        rptids93.add(new ValueNode("U4",93));
        reportEventNodes.add(createReportEvent("93",PID18Runnable.CEID_Type,rptids93));

        List<ValueNode> rptids110 = new ArrayList<>();
        rptids110.add(new ValueNode("U4",110));
        reportEventNodes.add(createReportEvent("110",PID18Runnable.CEID_Type,rptids110));

        List<ValueNode> rptids111 = new ArrayList<>();
        rptids111.add(new ValueNode("U4",111));
        reportEventNodes.add(createReportEvent("111",PID18Runnable.CEID_Type,rptids111));

        List<ValueNode> rptids120 = new ArrayList<>();
        rptids120.add(new ValueNode("U4",120));
        reportEventNodes.add(createReportEvent("120",PID18Runnable.CEID_Type,rptids120));

        List<ValueNode> rptids121 = new ArrayList<>();
        rptids121.add(new ValueNode("U4",121));
        reportEventNodes.add(createReportEvent("121",PID18Runnable.CEID_Type,rptids121));

        List<ValueNode> rptids130 = new ArrayList<>();
        rptids130.add(new ValueNode("U4",130));
        reportEventNodes.add(createReportEvent("130",PID18Runnable.CEID_Type,rptids130));


        S2F35MesRequestBody s2F35MesRequestBody = new S2F35MesRequestBody(reportEventNodes);
        mesResponse.setBody(JSONObject.toJSONString(s2F35MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid10",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F35_ReportAndEventUnLinked")
    public void S2F35_ReportAndEventUnLinked() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","LinkEventReport","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<ReportEventNode> reportEventNodes = new ArrayList<>();

        //把ceid=101 下的所有reportid 全部解绑
        List<ValueNode> rptids = new ArrayList<>();
        reportEventNodes.add(createReportEvent("101",PID18Runnable.CEID_Type,rptids));

        S2F35MesRequestBody s2F35MesRequestBody = new S2F35MesRequestBody(reportEventNodes);
        mesResponse.setBody(JSONObject.toJSONString(s2F35MesRequestBody));
        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F37")
    public void S2F37() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","EDableReport","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<String> ceids = new ArrayList<>();
        ceids.add("101");
        ceids.add("102");
        ceids.add("103");

        S2F37MesRequestBody s2F37MesRequestBody = new S2F37MesRequestBody(ceids,"U4",true);
        mesResponse.setBody(JSONObject.toJSONString(s2F37MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S2F37_enableAllEventReport")
    public void S2F37_enableAllEventReport() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","EDableReport","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<String> ceids = new ArrayList<>();


        S2F37MesRequestBody s2F37MesRequestBody = new S2F37MesRequestBody(ceids,"U4",true);
        mesResponse.setBody(JSONObject.toJSONString(s2F37MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }


    //pid18 没有远程指令
    @PostMapping("/S2F41")
    public void S2F41() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RemoteCMD","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<CPArgNode> cpArgNodes = new ArrayList<>();
        cpArgNodes.add(new CPArgNode("InfeedState","A","1","U1"));
        cpArgNodes.add(new CPArgNode("ProcInletState","A","21","U1"));
        RCMDNode rcmdNode = new RCMDNode("RRCMD1", "A", cpArgNodes);


        S2F41MesRequestBody s2F41MesRequestBody = new S2F41MesRequestBody(rcmdNode);
        mesResponse.setBody(JSONObject.toJSONString(s2F41MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    //pid18 没有远程指令
    @PostMapping("/S2F49")
    public void S2F49() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","EnhancedRemoteCMD","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
        List<CPArgNode> cpArgNodes = new ArrayList<>();
        cpArgNodes.add(new CPArgNode("InfeedState","A","1","U1"));
        cpArgNodes.add(new CPArgNode("ProcInletState","A","21","U1"));
        ERCMDNode rcmdNode = new ERCMDNode( "1","RRCMD1","A", cpArgNodes);


        S2F49MesRequestBody s2F49MesRequestBody = new S2F49MesRequestBody(rcmdNode);
        mesResponse.setBody(JSONObject.toJSONString(s2F49MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }



    @PostMapping("/S5F3")
    public void S5F3() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","EDAlarm","pid18");

        mesResponse.setHeader(header);

        //构建body   开始
//        //1.数组 list,enable/disable 具体的几个alid
//        int[] alids = new int[3];
//        alids[0] = 1;
//        alids[1] = 2;
//        alids[2] = 3;


        //2.enable/disable 所有alid
        int[] alids = new int[0];


        S5F3MesRequestBody s5F3MesRequestBody = new S5F3MesRequestBody(alids,PID18Runnable.ALID_Type,true);
        mesResponse.setBody(JSONObject.toJSONString(s5F3MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S5F5")
    public void S5F5() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestAlarmList","pid18");

        mesResponse.setHeader(header);

        //构建body   开始

        //        //1.数组 list,查询 具体的几个alid
//        int[] alids = new int[3];
//        alids[0] = 1;
//        alids[1] = 2;
//        alids[2] = 3;


        //2.查询 所有alid
        int[] alids = new int[0];


        S5F5MesRequestBody s5F5MesRequestBody = new S5F5MesRequestBody(alids,PID18Runnable.ALID_Type);
        mesResponse.setBody(JSONObject.toJSONString(s5F5MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }


    @PostMapping("/S6F23")
    public void S6F23() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestSpool","pid18");

        mesResponse.setHeader(header);

        //构建body   开始

        //        //1.数组 list,查询 具体的几个alid
        S6F23MesRequestBody s6F23MesRequestBody = new S6F23MesRequestBody(0);
        mesResponse.setBody(JSONObject.toJSONString(s6F23MesRequestBody));


        //构建body   结束

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }

    @PostMapping("/S7F19")
    public void S7F19() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestRecipeList","pid18");

        mesResponse.setHeader(header);

        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }


    //todo  ppid、ppidType 问设备要来
    @PostMapping("/S7F5")
    public void S7F5() throws Exception {
        MesRequestMessage mesResponse = new MesRequestMessage();

        Header header = new Header("Request","Execute","RequestPPbody","pid18");

        mesResponse.setHeader(header);

        S7F5MesRequestBody s7F5MesRequestBody = new S7F5MesRequestBody("33","Binary");
        //S7F5MesRequestBody s7F5MesRequestBody = new S7F5MesRequestBody("asd","A");

        mesResponse.setBody(JSONObject.toJSONString(s7F5MesRequestBody));


        String integer= HttpUtil.post("localhost:8010/mesRequest/pid18",JSONObject.toJSONString(mesResponse));
        JSONObject jsonObject = JSONObject.parseObject(integer);
        System.out.println("res : "+integer);
    }



}
